window.onload=function(){
var img=$(".banner1")
var lis=$("li",$(".middleli")[0])
var movein1=$(".middle")
var now=0
var kuan=parseInt(window.getComputedStyle(img[0],null)["width"])
var yiruxuanxiangka=$(".yiruxuanxiangka")
var bigxuanxiangka=$(".bigxuanxiangka")
var dingwei=$(".dingwei")
var btnL=$(".btnL")[0]
var btnR=$(".btnR")[0]
var hongdian1=$(".hongdian1")[0]
var flag=true
//顶部选项卡
for (var y = 0; y <bigxuanxiangka.length; y++) {
	   yiruxuanxiangka[y].bb=y
	   yiruxuanxiangka[y].onmouseover=function(){
	   bigxuanxiangka[this.bb].style.display="block"
	   dingwei[this.bb].style.background="#f7f7f7"
	   dingwei[this.bb].style.color="#0085d0"
	   }
	   yiruxuanxiangka[y].onmouseout=function(){
	   bigxuanxiangka[this.bb].style.display="none"
       dingwei[this.bb].style.background=""
       dingwei[this.bb].style.color=""
	   }
};


 // 无缝轮播

  
var next=0
var t=setInterval(move,2000)
function move(){
	next++
	if (next==img.length) {
		next=0
	};			
    
	lis[next].style.backgroundColor="#e40077"
	img[next].style.left=kuan+"px"
	animate(img[now],{left:-kuan})
	animate(img[next],{left:0},function(){flag=true})
	lis[now].style.backgroundColor=""

		now=next

    

}
//移入停止
    movein1[0].onmouseover=function(){
    	clearInterval(t)
    }
    movein1[0].onmouseout=function(){
    	 t=setInterval(move,2000)
    }
 // 点击无缝   
        
     for (var i = 0; i <lis.length; i++) {
           lis[i].index=i         
           lis[i].onclick=function(){
            if (flag==false) {
               return
            }
            flag=false
            for (var i = 0; i <img.length; i++) {
               lis[i].style.background=""
               
            }
        if (this.index>now) {
         animate(img[now],{left:-kuan},600)
      img[this.index].style.left=kuan+"px"
      animate(img[this.index],{left:0},600,function(){flag=true})
      now=this.index
        }
        else{animate(img[now],{left:kuan},600,function(){flag=true})
      img[this.index].style.left=-kuan+"px"
      animate(img[this.index],{left:0},600)
      now=this.index
      }
      
      lis[this.index].style.background="#e40077"
      now=this.index

     }
  }
   btnL.onclick=function(){
      if (flag==false) {
         return
      }
      flag=false
      move1()

   }
   btnR.onclick=function(){
      if (flag==false) {
         return
      }
      flag=false
      move()
   }
   function move1 (){  
    next=now-1
    if (next<0) {
        next=img.length-1
    }
    for (var i = 0; i < img.length; i++) {
       lis[i].style.background=""
       if (i==0) {
         continue
       }
       
    }
    img[next].style.left=-kuan+"px"
    animate(img[now],{left:kuan})
    animate(img[next],{left:0},Tween.Quad.easeInOut,function(){flag=true})
         now=next
         
         lis[now].style.background="#e40077"
  }
 //节点轮播
var mid=$(".mid")[0]
var one=$(".one")
var bigbox=$(".bigbox")[0]
var kuan1=parseInt(getStyle(one[0],"width"))
var t1=setInterval(movejiedian,2000)
var btnL1=$(".btnL1")[0]
var btnR1=$(".btnR1")[0]
function movejiedian(){
   animate(bigbox,{left:-kuan1},1000,function(){
   	var first=firstChild(bigbox)
   	bigbox.appendChild(first)
   	bigbox.style.left=0
   	flag=true
   })
}
function movejiedian1(){
   bigbox.style.left=-kuan1+"px"
   var first=firstChild(bigbox)	
   var last=lastChild(bigbox)
   bigbox.insertBefore(last,first)
   animate(bigbox,{left:0},1000,function(){
   	flag=true
   })
}  
mid.onmouseover=function(){
	clearInterval(t1)
}
mid.onmouseout=function(){
	t1=setInterval(movejiedian,2000)
}
btnL1.onclick=function(){
	if (flag==false) {
		return
	}
	flag=false
	movejiedian()
}
btnR1.onclick=function(){
	if (flag==false) {
		return
	}
	flag=false
	movejiedian1()
}


}